//
//  AppDelegate+Wechat.swift
//  YPWatermarkCamera
//
//  Created by 赵新 on 2022/8/8.
//

import Foundation

let WechatAppId = "wx8a7230a5ff99f638"

extension AppDelegate {
    /// 初始化微信
    func configWechat() {
        WXApi.registerApp(WechatAppId, universalLink: "https://wmc.cdzbb.cn/watermarkCamera/")
    }

    /// 通过universal link来唤起app
    func wechatHandleOpenUniversalLink(_ application: UIApplication,
                                       continue userActivity: NSUserActivity,
                                       restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool
    {
        return WXApi.handleOpenUniversalLink(userActivity, delegate: self)
    }

    /// iOS9+，通过url scheme来唤起app
    func wechatHandleOpen(_ app: UIApplication,
                          open url: URL,
                          options: [UIApplication.OpenURLOptionsKey: Any] = [:]) -> Bool
    {
        return WXApi.handleOpen(url, delegate: self)
    }
}

// MARK: - 扩展AppDelegate + WXApiDelegate

extension AppDelegate: WXApiDelegate {
    func onResp(_ resp: BaseResp) {}
}
